package com.itheima.a01test5;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Serve {
    public static void main(String[] args) throws IOException {
        /*
         客户端发送数据 接收反馈
         服务端进行接收 进行反馈
        */
        ServerSocket ss = new ServerSocket(10000);

        //2.进行连接
        Socket socket = ss.accept();
        //接收数据
        InputStream is = socket.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);

        //读取
        int b;
        while((b= isr.read())!=-1){
            System.out.print((char)b);
        }

        //进行数据反馈
        String str = "有多高兴";
        OutputStream os = socket.getOutputStream();
        os.write(str.getBytes());

        ss.close();
        socket.close();
    }
}
